package com.ruoyi.workbench.service.impl;

import com.ruoyi.workbench.domain.WorkCollaboration;
import com.ruoyi.workbench.mapper.WorkCollaborationMapper;
import com.ruoyi.workbench.service.WorkCollaborationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 协同需求(WorkCollaboration)表服务实现类
 *
 * @author makejava
 * @since 2024-07-04 10:53:03
 */
@Service("workCollaborationService")
public class WorkCollaborationServiceImpl implements WorkCollaborationService {
    @Resource
    private WorkCollaborationMapper workCollaborationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param collaborationRequestId 主键
     * @return 实例对象
     */
    @Override
    public WorkCollaboration queryById(Long collaborationRequestId) {
        return this.workCollaborationDao.queryById(collaborationRequestId);
    }

//    /**
//     * 分页查询
//     *
//     * @param workCollaboration 筛选条件
//     * @param pageRequest      分页对象
//     * @return 查询结果
//     */
//    @Override
//    public List<WorkCollaboration> queryByPage(WorkCollaboration workCollaboration, PageRequest pageRequest) {
//        long total = this.workCollaborationDao.count(workCollaboration);
//        return new PageImpl<>(this.workCollaborationDao.queryAllByLimit(workCollaboration, pageRequest), pageRequest, total);
//    }

    /**
     * 新增数据
     *
     * @param workCollaboration 实例对象
     * @return 实例对象
     */
    @Override
    public WorkCollaboration insert(WorkCollaboration workCollaboration) {
        this.workCollaborationDao.insert(workCollaboration);
        return workCollaboration;
    }

    @Override
    public int insertBatch(List<WorkCollaboration> entities) {
        return workCollaborationDao.insertBatch(entities);
    }

    /**
     * 修改数据
     *
     * @param workCollaboration 实例对象
     * @return 实例对象
     */
    @Override
    public WorkCollaboration update(WorkCollaboration workCollaboration) {
        this.workCollaborationDao.update(workCollaboration);
        return this.queryById(workCollaboration.getCollaborationRequestId());
    }

    /**
     * 通过主键删除数据
     *
     * @param collaborationRequestId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long collaborationRequestId) {
        return this.workCollaborationDao.deleteById(collaborationRequestId) > 0;
    }
}
